//
//  ForgetPasswordViewController.m
//  atXiaoGeBClient
//
//  Created by Linyu Niu on 12/04/2018.
//  Copyright © 2018 Linyu Niu. All rights reserved.
//

#import "ForgetPasswordViewController.h"

@interface ForgetPasswordViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView * forgetTable;
}
@end

@implementation ForgetPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    __weak ForgetPasswordViewController * weakSelf = self;
   UIView * navView = [[CTMediator sharedInstance] navgationHeadViewInTargetView:self.view params:[NSDictionary dictionaryWithObjectsAndKeys:@"下一步",@"rightTitle",@"忘记密码",@"title", nil] leftAction:^(UIButton * sender){
        [weakSelf.navigationController popViewControllerAnimated:YES];
   } rightAction:^(UIButton * sender){
       
   }];
    forgetTable = [self addTableViewInView:self.view frame:CGRectMake(0, navView.frame.origin.y + navView.frame.size.height, self.view.frame.size.width, self.view.frame.size.height - navView.frame.origin.y - navView.frame.size.height) delegateAndDataSource:self];
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ElementTableViewCell * cell = [[ElementTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    NSInteger xSpace = 30;
    
    UITextField * field = [[UITextField alloc]initWithFrame:CGRectMake(xSpace, 0, tableView.frame.size.width - 2 * xSpace, 25)];
    field.font = [UIFont systemFontOfSize:14];
    
    field.textColor = [UIColor whiteColor];//[UIColor colorWithRed:64.0 / 255.0 green:78.0 / 255.0 blue:89.0 / 255.0 alpha:1.0];
    [cell addSubview:field];
    if ([indexPath row] == 0) {
        UILabel * nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 5, 40, 25)];
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.text = @"+86";
        [nameLabel enlargeWidthToKeepFontSize];
        //            nameLabel.textColor = [UIColor whiteColor];
        [cell addSubview:nameLabel];
        field.placeholder = @"请输入手机号码";
        
        UIView * vLine = [[UIView alloc]initWithFrame:CGRectMake(nameLabel.frame.origin.x + nameLabel.frame.size.width + 4, nameLabel.frame.origin.y + 3, 0.5, nameLabel.frame.size.height - 6)];
        vLine.backgroundColor = [UIColor colorWithRed:228.0 / 255.0 green:228.0 / 255.0 blue:228.0 / 255.0 alpha:1.0];
        [cell addSubview:vLine];
        
        field.frame = CGRectMake(vLine.frame.origin.x + vLine.frame.size.width + 5, vLine.frame.origin.y, tableView.frame.size.width - vLine.frame.origin.x - xSpace, vLine.frame.size.height);
    }else if([indexPath row] == 1){
        field.placeholder = @"请输入验证码";
        UIButton * sendCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        sendCodeButton.frame = CGRectMake(tableView.frame.size.width - xSpace - 85, 10, 85, field.frame.size.height);
        sendCodeButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [sendCodeButton setTitleColor:[UIColor colorWithRed:64.0 / 255.0 green:198.0 / 255.0 blue:124.0 / 255.0 alpha:1.0] forState:UIControlStateNormal];
        sendCodeButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [sendCodeButton setTitle:@"发送验证码" forState:UIControlStateNormal];
        [cell addSubview:sendCodeButton];
        
        field.frame = CGRectMake(field.frame.origin.x, 10, tableView.frame.size.width - xSpace * 2 - sendCodeButton.frame.size.width - 5, field.frame.size.height);
    }
    
    cell.cellHeight = field.frame.size.height + field.frame.origin.y + 10;
    
    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(xSpace, cell.cellHeight - 1.0, tableView.frame.size.width - 2 * xSpace, 1.0)];
    lineView.backgroundColor = [UIColor colorWithRed:228.0 / 255.0 green:228.0 / 255.0 blue:228.0 / 255.0 alpha:1.0];
    [cell addSubview:lineView];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    ElementTableViewCell * cell = (ElementTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.cellHeight;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

@end
